﻿/**********************************************************************************
 * Project Name :   
 * Remarks      :  
 * Class Name   :  RepositoryTest 
 * Version      :  v1.0.0.0 
 * Author       :  Joey Liang 
 * Description  :  
 * Created Time :  2013/11/1 22:44:22
 * Update Man   :  Joey Liang
 * Update Time  :  2013/11/1 22:44:22
************************************************************************/

using IdleTest.MSTest;
using IdleTest.EFAndMVCDemo.IRepositories;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace IdleTest.EFAndMVCDemo.RepositoryTest
{
    public abstract class RepositoryTest<TEntity, TKey> where TEntity : class
    {
        protected abstract IRepository<TEntity, TKey> Repository { get; }

        public virtual void GetSingleTest()
        {
            AssertCommon.IsNull(true, Repository.GetSingle(default(TKey)));
        }

        public virtual void InsertTest()
        {
            AssertCommon.ThrowException(true, () => Repository.Insert(default(TEntity)));
            AssertCommon.ThrowException(true, () => Repository.Insert(null));
        }  
    }
}
